<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-edit" th:object="${project}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目编号：</label>
                <div class="col-sm-8">
                    <input name="projectCode" th:field="*{projectCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商机：</label>
                <div class="col-sm-8">
                    <select name="opportunityId"class="form-control" th:with="type=${@customDictService.selectDictOpportunity()}">
                        <option value="">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.id}" th:field="*{opportunityId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目类型：</label>
                <div class="col-sm-8">
                    <select name="projectType" id="projectType" class="form-control" th:field="*{projectType}" th:with="type=${@dict.getType('project_type')}" disabled>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">事业部：</label>
                <div class="col-sm-8">
                    <select name="businessUnitId" class="form-control" th:field="*{businessUnitId}"  th:with="type=${@customDictService.selectDictBusinessUnitWithDepartments()}" required>
                        <option value="">请选择</option>
                        <optgroup th:each="unit: ${type}" th:label="${unit.name}">
                            <option th:each="department : ${unit.departments}" th:text="${department.name}" th:value="${department.id}"></option>
                        </optgroup>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目简称：</label>
                <div class="col-sm-8">
                    <input name="shortTitle" th:field="*{shortTitle}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户：</label>
                <div class="col-sm-8">
                    <select name="customerId"  class="form-control m-b" th:field="*{customerId}" th:with="type=${@customDictService.selectDictCustomer()}">
                        <option value="0">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.title}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开工时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="kickoffDate" th:value="${#dates.format(project.kickoffDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" th:if="${project.projectType != 'staffing'}" id="amount">
                <label class="col-sm-3 control-label">合同金额：</label>
                <div class="col-sm-8">
                    <input name="amount"  th:field="*{amount}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目阶段：</label>
                <div class="col-sm-8">
                    <select name="projectStage" class="form-control" th:field="*{projectStage}" th:with="type=${@dict.getType('project_stage')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">税率(%)：</label>
                <div class="col-sm-8">
                    <input name="tax" th:field="*{tax}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目经理：</label>
                <div class="col-sm-8">
                    <select name="projectManager"  class="form-control m-b" th:field="*{projectManager}" th:with="type=${@customDictService.selectUserList()}">
                        <option value="0">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.userName}" th:value="${dict.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商务经理：</label>
                <div class="col-sm-8">
                    <select name="accountManager"  class="form-control m-b" th:field="*{accountManager}" th:with="type=${@customDictService.selectUserList()}">
                        <option value="0">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.userName}" th:value="${dict.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">交付经理：</label>
                <div class="col-sm-8">
                    <select name="deliveryManager"  class="form-control m-b" th:field="*{deliveryManager}" th:with="type=${@customDictService.selectUserList()}">
                        <option value="0">无</option>
                        <option th:each="dict : ${type}" th:text="${dict.userName}" th:value="${dict.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目描述：</label>
                <div class="col-sm-8">
                    <textarea name="description" th:field="*{description}" rows="6" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "erp/project";
        $("#form-project-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-project-edit').serialize());
            }
        }

        $("input[name='kickoffDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

    </script>
</body>
</html>